package ManagerRmi;

import java.rmi.Naming;
import java.rmi.RemoteException;
import POJO.*;

public class ManagerRmi implements RmiInterface{
RmiInterface rmiInterface;
	
	public void init() {
		try {   
            String url = "//localhost:8806/SAMPLE-SERVER1";   
            rmiInterface = (RmiInterface) Naming.lookup(url);
        } catch (RemoteException rex) {   
            System.out.println("Error in lookup: " + rex.toString());   
        } catch (java.net.MalformedURLException me) {   
            System.out.println("Malformed URL: " + me.toString());   
        } catch (java.rmi.NotBoundException ne) {   
            System.out.println("NotBound: " + ne.toString());   
        }
	}
	
	public SignInStatePOJO findManager(SignInPOJO signInPOJO) {
		try {
			return rmiInterface.findManager(signInPOJO);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		return null;
	}
	public PromotionInfoPOJO findPromotion() {
		try {
			return rmiInterface.findPromotion();
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		return null;
	}
	public void updatePromotion(PromotionInfoPOJO promotionInfoPOJO) {
		try {
			rmiInterface.updatePromotion(promotionInfoPOJO);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}
	public void updateCustomerPromotionInfo(PromotionPOJO promotionPOJO) {
		try {
			rmiInterface.updateCustomerPromotionInfo(promotionPOJO);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}
}
